#pragma once

class CKernel:
	public IKernel
{
public:
	CKernel();
	~CKernel();

	void			CreateGameWindow(const std::string& title, uint width, uint height, bool fullscreen, bool vsync);
	void			SwapBuffers();

	inline uint		GetTicks();
	inline void		Delay(int miliseconds);
	float			GetDeltaTime();

	void			RegisterThread(IThread* thread);
	void			UnregisterThread(IThread* thread);

	void			InifityLoop();
	void			LockThread(IThread* thread);
	void			StopThreads();

	ITimer*			CreateNewTimer();
	IMutex*			CreateNewMutex();

	void			Close();

private:
	void			StartThreads(EThread::Type type);
	void			WaitThreads(EThread::Type type);

	SDL_Window*		m_window;
	SDL_Renderer*	m_renderer;
	void*			m_glcontext;

	bool			m_continueLoop;
	float			m_deltaTime;

	IMutex*					m_threadsVectorMutex;
	std::vector<IThread*>	m_threads;
	
	std::string		m_title;
	uint			m_resx;
	uint			m_resy;
	bool			m_fullscreen;
	bool			m_vsync;
};

